/* eslint-disable jsx-a11y/label-has-associated-control */

/**
 * 表单末尾按钮栏
 * @Author Lianqi
 * @Date 2022/7/7
 * @description 从FormMain.js中抽取；
 */

import { Form, Button, Space } from 'antd'
import { MODE } from '../config/Constant'
import ButtonIcon from '../../fc-icon/ButtonIcon'

const tailFormItemId = 'tailButtonCol'

function FormButtonBar(props) {
  const { extraTail, mode, resetButton, handleReset, submitButton } = props

  return (
    <Form.Item key="tailButton" wrapperCol={{span: 24}}>
      <Space id={tailFormItemId}>
        {extraTail}
        {mode === MODE.EDIT && resetButton.show ? (
          <Button
            onClick={handleReset}
            icon={resetButton.icon ? <ButtonIcon iconType={resetButton.icon} /> : null}
            // disabled={disabled}
          >
            {resetButton.label || '重置'}
          </Button>
        ) : null}
        {mode === MODE.EDIT && submitButton.show ? (
          <Button
            type="primary"
            htmlType="submit"
            icon={submitButton.icon ? <ButtonIcon iconType={submitButton.icon} /> : null}
            // disabled={disabled}
          >
            {submitButton.label || '查询'}
          </Button>
        ) : null}
      </Space>
    </Form.Item>
  )
}

export default FormButtonBar
